package com.jishuo.nontax.bean.vo;

import com.jishuo.base.util.GsonUtil;
import com.jishuo.base.util.StringObject;
import com.jishuo.nontax.bean.bank.EticketNum;
import com.jishuo.nontax.bean.bank.EticketNumDetail;
import com.jishuo.nontax.bean.bank.EticketNumNew;
import com.jishuo.nontax.bean.message.SetEticketNum;
import com.jishuo.nontax.bean.message.SetEticketNumBackOut;
import lombok.Data;
import org.apache.commons.lang.StringUtils;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.ArrayList;

@SuppressWarnings("serial")
@Data
public class EticketNumVO implements Serializable {
	private int rownum;
	private long billid;
	private String billnum; // 缴款书
	private String filldate;  //填写日期
	private String eticketnum; // 电子缴款书
	private String admdivcode; // 区划id
	private String agencycode; // 区划编码
	private String agencyname; // 区划名称

	private String payer; // 缴款人
	private String payeraccount;// 缴款人账号
	private String payerbank; // 缴款人开户银行
	private int bankid;
	private String payee; // 收款户名
	private String payeeaccount; // 收款银行账号
	private String payeebank; // 收款银行开户行
	private BigDecimal amt; // 票面金额
	private String paybankdt; // 收款时间
	private String bankstation; // 收款网点
	private String bankaffirm; // 交易流水号
	private int payway; // 缴款方式
	private int billstate; // 传输状态
	public String sendtime;

	public String writename; //经办人
	public String writedate; //经办日期
	private int isbankaffirm;
	private int issend;
	private String  payinfo;
    private String vertifycode;
	private long messageid;

	public EticketNumVO() {};

	// 从SetEticketNum获得数据
	public EticketNumVO(SetEticketNum bean) {
		this.admdivcode = bean.getAdmdivcode();
		this.agencycode = bean.getAgencycode();
		this.agencyname = bean.getAgencyname();
		this.amt = new BigDecimal(bean.getAmt());
		this.billnum = bean.getBillnum();
		this.filldate = bean.getFilldate();
		this.payee = bean.getPayee();
		this.payeeaccount = bean.getPayeeaccount();
		this.payeebank = bean.getPayeebank();
		this.payer = bean.getPayer();
		this.payeraccount = bean.getPayeraccount();
		this.payerbank = bean.getPayerbank();
		this.payinfo = bean.getPayinfo();
		this.vertifycode = bean.getVertifycode();
	}

	// 返回EticketNum类
	public EticketNum getEticketNum() {
		EticketNum bean = new EticketNum();
		bean.setBillstate(StringObject.objectString(billstate));
		bean.setBillnum(this.billnum);
		bean.setAdmdivcode(this.admdivcode);
		bean.setAgencycode(this.agencycode);
		bean.setAgencyname(this.agencyname);
		bean.setAmt(StringObject.objectString(amt));
		bean.setFilldate(this.filldate);
		bean.setPayee(this.payee);
		bean.setPayeeaccount(this.payeeaccount);
		bean.setPayeebank(this.payeebank);
		bean.setPayer(this.payer);
		bean.setPayeraccount(this.payeraccount);
		bean.setPayerbank(this.payerbank);
		bean.setPayinfo(this.payinfo);
		bean.setVertifycode(this.vertifycode);
		return bean;
	}

	// 返回EticketNum类
	public EticketNumNew getEticketNumNew() {
		EticketNumNew bean = new EticketNumNew();
		bean.setBillstate(StringObject.objectString(billstate));
		bean.setBillnum(this.billnum);
		bean.setAdmdivcode(this.admdivcode);
		bean.setAgencycode(this.agencycode);
		bean.setAgencyname(this.agencyname);
		bean.setAmt(StringObject.objectString(amt));
		bean.setFilldate(this.filldate);
		bean.setPayee(this.payee);
		bean.setPayeeaccount(this.payeeaccount);
		bean.setPayeebank(this.payeebank);
		bean.setPayer(this.payer);
		bean.setPayeraccount(this.payeraccount);
		bean.setPayerbank(this.payerbank);
		bean.setVertifycode(this.vertifycode);
		bean.setIsbankaffirm(StringObject.objectString(this.isbankaffirm));
		bean.setList(jsonToList(this.payinfo, EticketNumDetail.class));
		bean.setPayinfo("");
		return bean;
	}

	// 将jsonArray字符串转换成List集合
	public static ArrayList<EticketNumDetail> jsonToList(String json, Class beanClass) {
		if (!StringUtils.isBlank(json)) {
			return (ArrayList)GsonUtil.fromJsonToList(json, beanClass);
		} else {
			return null;
		}
	}

	//返回  SetEticketNumBackOut  对象
	public SetEticketNumBackOut getSetEticketNumBackOut(){
		SetEticketNumBackOut seteticketNum = new SetEticketNumBackOut();
		seteticketNum.setAdmdivcode(this.admdivcode);
		seteticketNum.setAgencycode(this.agencycode);
		seteticketNum.setAgencyname(this.agencyname);
		seteticketNum.setAmt(StringObject.objectString(amt));
		seteticketNum.setBankaffirm(this.bankaffirm);
		seteticketNum.setBankstation(this.bankstation);
		seteticketNum.setBillnum(this.billnum);
		seteticketNum.setFilldate(this.filldate);
		seteticketNum.setPayee(this.payee);
		seteticketNum.setPayeeaccount(this.payeeaccount);
		seteticketNum.setPayeebank(this.payeebank);
		seteticketNum.setPayer(this.payer);
		seteticketNum.setPayeraccount(this.payeraccount);
		seteticketNum.setPayerbank(this.payerbank);
		seteticketNum.setVertifycode(this.vertifycode);
		return  seteticketNum;
	}
}
